package com.tgy.leetcode;

/**
 * https://leetcode-cn.com/problems/ugly-number/
 */

public class _263_丑数 {

    public static boolean isUgly(int n) {

        if (n <= 0) {

            return false;
        }

        while (true) {
            if ((n & 1) == 0) {

                n = n >> 1;
            }else if ( n % 3 == 0) {

                n = n / 3;
            }else if (n % 5 == 0) {

                n = n / 5;
            }else {

                return n == 1;
            }

        }
    }

    public static void main(String[] args) {

        System.out.println(isUgly(-2147483648));
    }
}
